/**
 * 
 */
package qy.jalgotrade.optimizer.base;

import java.io.Serializable;
import java.util.function.Predicate;

/**
 * @author c-geo
 *
 */
public class OptimizingGoal implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1077271706412168525L;

	private Results.KPI __goalKpi;

	private Predicate<Results> __constraintsCondition;

	private String __ccExpr;

	private boolean __recordAllResults;

	/**
	 * 
	 */
	public OptimizingGoal() {

		this(Results.KPI.RESULT, null, "", false);
	}

	/**
	 * 
	 * @param goalKpi
	 */
	public OptimizingGoal(Results.KPI goalKpi) {

		this(goalKpi, null, "", false);
	}

	/**
	 * 
	 * @param goalKpi
	 * @param cc
	 */
	public OptimizingGoal(Results.KPI goalKpi, Predicate<Results> cc) {

		this(goalKpi, cc, "", false);
	}

	/**
	 * 
	 * @param goalKpi
	 * @param cc
	 * @param ccExpr
	 */
	public OptimizingGoal(Results.KPI goalKpi, Predicate<Results> cc, String ccExpr) {

		this(goalKpi, cc, ccExpr, false);
	}

	/**
	 * 
	 * @param goalKpi
	 * @param cc
	 * @param ccExpr
	 * @param recordAllResults
	 */
	public OptimizingGoal(Results.KPI goalKpi, Predicate<Results> cc, String ccExpr, boolean recordAllResults) {

		__goalKpi = goalKpi;
		__constraintsCondition = cc;
		if (ccExpr != null) {
			__ccExpr = ccExpr;
		} else {
			__ccExpr = "";
		}
		__recordAllResults = recordAllResults;
	}

	/**
	 * 
	 * @return
	 */
	public Results.KPI getGoalKpi() {

		return __goalKpi;
	}

	/**
	 * 
	 * @return
	 */
	public Predicate<Results> getConstraintsCondition() {

		return __constraintsCondition;
	}

	/**
	 * 
	 * @return
	 */
	public boolean getRecordAllResults() {

		return __recordAllResults;
	}

	@Override
	public String toString() {

		return String.format("OptimizingGoal {kpi: %s, cc: %s}", __goalKpi,
		        __ccExpr != null && __ccExpr.length() > 0 ? __ccExpr : "null");
	}
}
